﻿CREATE PROCEDURE [dbo].[sp_Get_AccountWithoutOrder]
	@PeroidYear varchar(4), 
	@PeroidMonth varchar(2),
	@Type int
AS
	select a.Email, a.AccountID,a.DivisionNum from 
	(select ac.Email, ac.AccountID, ac.AccountType,ac.DivisionNum from dbo.Accounts ac 
	where ac.AccountID in (select distinct(MdNumber) from dbo.ZipInfo)) a
	left join dbo.Orders o on a.AccountID = o.AccountID
	and o.PeroidYear = @PeroidYear and o.PeroidMonth = @PeroidMonth
	where (o.OrderID is null or o.IsPurchased = 0)
	and a.AccountType = @Type 

